<?php
    $this->headTitle($this->__('Manage Users') . ' » ', Zend_View_Helper_Placeholder_Container_Abstract::PREPEND);

    $this->headScript()->appendFile("http://www.datatables.net/release-datatables/media/js/jquery.dataTables.js");

    $this->stylesheet()->controller();
?>


<a href="<?php echo $this->url(array(), 'userscreate')?>" class="button"><?php echo $this->__('Add User')?></a>

<div class="clear">&nbsp;</div>

<table id="userGrid" width="100%">
    <thead>
        <tr>
            <?php foreach ($this->columns as $column):?>
                <th><?php echo $column?></th>
            <?php endforeach;?>
            <th><?php echo $this->__('Edit')?></th>
            <th><?php echo $this->__('Delete')?></th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td colspan="5" class="dataTables_empty">Loading data from server</td>
        </tr>
    </tbody>
</table>


<script type="text/javascript">
$(function() {
	$('#userGrid').dataTable({
	    "bJQueryUI": true,
		"bProcessing": true,
		"bServerSide": true,
		"sAjaxSource": "<?php echo $this->url()?>",
		"aoColumns": [
            <?php foreach ($this->columns as $i => $column):?>
				{ "mDataProp": "<?php echo $column?>" }<?php //if (count($this->columns) != $i+1):?>,<?php //endif?>
			<?php endforeach;?>
			{ "mDataProp": "editUrl" },
			{ "mDataProp": "deleteUrl"}
					]
	});
    $('#userGrid_wrapper').addClass('ui-widget-content ui-corner-all');

    $('#userGrid').delegate('.delete', 'click', function(e){
       if (!confirm(this.title)) {
           e.preventDefault();
       }
    });
});
</script>